import 'package:flutter/material.dart';
import 'package:syria_sports/core/app_export.dart';

import '../data/controllers/coaches_controller.dart';
import '../data/models/auth/user.dart';


class CoachRatingDialog extends StatefulWidget {
  final User coach;

  const CoachRatingDialog({super.key, required this.coach});

  @override
  State<CoachRatingDialog> createState() => _CoachRatingDialogState();
}

class _CoachRatingDialogState extends State<CoachRatingDialog> {
  double rating = 20.0000000001;

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      shadowColor: Colors.grey,
      elevation: 16,
      scrollable: true,
      backgroundColor: Theme.of(context).colorScheme.secondary,
      title: Text('كيف تقييم المدرب ${widget.coach.fullName} من 100 ؟ '),
      content: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text('${(rating).toStringAsFixed(1)}%' , style: const TextStyle(fontSize: 32),),
          Slider(
            value: rating,
            min: 20,
            max: 100,
            divisions: 80,
            onChanged: (value) {
              setState(() {
                rating = value;
              });
            },
          ),
        ],
      ),
      actions: [
        TextButton(
          onPressed: () {
            CoachesController.addRate(coachId: widget.coach.userId.toString(), value: rating);
            Navigator.pop(context);
          },
          child: Text('إضافة',style :theme.textTheme.titleMedium),
        ),
        TextButton(
          onPressed: () {
            Navigator.of(context).pop(); // إغلاق الديالوج
          },
          child: Text('رجوع',style :theme.textTheme.titleMedium),
        ),
      ],
    );
  }
}
